#include "SampleList.h"
#include "imgui.h"
#include "DefaultSample.h"
#include "GridSample.h"
#include "ShapesSample.h"
#include "TextureSample.h"
#include "ModelSample.h"
#include "CubeMapSample.h"
#include "NormalMapSample.h"
SampleList::SampleList(ID3D11Device* device, ID3D11DeviceContext* context) 
	: m_sample(nullptr),m_device(device),m_context(context)
{

}

SampleList::~SampleList()
{
	if (m_sample != nullptr)
	{
		delete m_sample;
		m_sample = nullptr;
	}
}

void SampleList::Update(float dt)
{
	if (m_sample)
	{
		m_sample->Update(dt);
	}
}

void SampleList::Render()
{
	if (m_sample)
	{
		m_sample->Render();
	}
}

void SampleList::GUI()
{
	ImGui::Begin("SampleList");
	if (m_sample)
	{
		m_sample->GUI();
		ImGui::Separator();
		if (ImGui::Button("Close"))
		{
			delete m_sample;
			m_sample = nullptr;
		}
	}
	else
	{
		if (ImGui::Button("DefaultSample"))
		{
			m_sample = new DefaultSample(m_device.Get(),m_context.Get());
		}

		if (ImGui::Button("GridSample"))
		{
			m_sample = new GridSample(m_device.Get(), m_context.Get());
		}

		if (ImGui::Button("ShapesSample"))
		{
			m_sample = new ShapesSample(m_device.Get(), m_context.Get());
		}

		if (ImGui::Button("TextureSample"))
		{
			m_sample = new TextureSample(m_device.Get(), m_context.Get());
		}

		if (ImGui::Button("ModelSample"))
		{
			m_sample = new ModelSample (m_device.Get(), m_context.Get());
		}

		if (ImGui::Button("CubeMapSample"))
		{
			m_sample = new CubeMapSample(m_device.Get(), m_context.Get());
		}

		if (ImGui::Button("NormalMapSample"))
		{
			m_sample = new NormalMapSample(m_device.Get(), m_context.Get());
		}
	}

	ImGui::End();
}

void SampleList::DrawFont()
{
	if (m_sample)
	{
		m_sample->DrawFont();
	}
}
